package cn.tianjindong.blog.pojo;

import java.text.SimpleDateFormat;
import java.util.Date;

public class BlogMessageBoard {
	private Long id;

	private String title;

	private String email;

	/**
	 * 管理员是否已读，未读0，已读1
	 */
	private Integer tab;

	private Date createtime;

	/**
	 * 管理员是否已经处理，0未处理，1已处理，2无用留言
	 */
	private Integer tagReply;

	private Long userId;

	private String content;

	private BlogUser user;

	private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public BlogUser getUser() {
		return user;
	}

	public void setUser(BlogUser user) {
		this.user = user;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title == null ? null : title.trim();
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email == null ? null : email.trim();
	}

	public Integer getTab() {
		return tab;
	}

	public void setTab(Integer tab) {
		this.tab = tab;
	}

	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}

	public Integer getTagReply() {
		return tagReply;
	}

	public void setTagReply(Integer tagReply) {
		this.tagReply = tagReply;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content == null ? null : content.trim();
	}

	/**
	 * 获取字符串形式的时间
	 * 
	 * @return
	 */
	public String getStringCreatetime() {
		if (this.createtime != null) {
			return dateFormat.format(this.createtime);
		}
		return null;
	}

	/**
	 * 获取内容的一部分
	 * @return
	 */
	public String getBriefTitle() {
		if (title != null) {
			if (title.length() > 15) {
				return this.title.substring(0, 15)+"...";
			}
			return this.title;
		}
		return null;
	}
}